// 主界面
;define(function(require, exports, module) {
    'use strict';
    var util = require("util");
    var base = require("base");
    var router = require("../hash/pageRouter");
    var nature = $("#nature").val();
	var enterpriseId;           
	var validate = require("validate");
	var tools = require("tools");
	var databind = require("databind");
	var enterAccountManage_details = require("./modifyClienManage_details.css");
	var accountId;
    var init = function(page){
    	accountId = page.params.accountId;
		$(".nav_active").removeClass("nav_active1");
		$(".authenticationState").addClass("nav_active1");
		inquireEnterpriseDetail(enterpriseId);
		router.init(); 
		initEvent();
    };
    
	var initEvent = function(){		
		$("#enterAccountManage_details").on("change", "#creditCard", function(){
			var bn = tools.getBankName($(this).val());
			if (bn == ""){
				alert("未知开户行！");
			} else {
				$("#depositBank").val(bn);
			}
		});
		
		//认证提交
		$("#enterAccountManage_details").on("click", ".next", function(){
			databind.submitDom($("#enterAccountManage_details"), function(){//获取div的id值通过HTML中的action="informationCheck"传到后台
				history.go(-1);
		  	});
		});

    };
    
	
	
    //查询企业详细信息
	var inquireEnterpriseDetail = function() {
		base.fnAjax({
			action: "queryAccountManagement.json",
			oData: {
				accountId: accountId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					databind.fillForm($("#enterAccountManage_details"), data.datas[0]);
					$("select[name=province]").html("<option>"+data.datas[0].province+"</option>");
					$("select[name=city]").html("<option>"+data.datas[0].city+"</option>");
			        $("select[name=district]").html("<option>"+data.datas[0].district+"</option>");
				} else {
					base.alert(2, data.message);
				}
			}
		});
		databind.disableInput("#content");
		databind.enableInput("#button-submit")
	};
	
    return {
        init:init
    };
});